package org.box.demos.multithreading.wgetmt.j16mt;

import org.box.demos.multithreading.wgetmt.core.URL;

/**
 * Represents a result of {@link DownloadTask}. TaskResult is thread safe
 * and immutable.
 * 
 * @author <a href="mailto:alexander.box@gmail.com">Alexander Korobka</a>
 * 
 */
public final class TaskResult {

	private final String groupId;
	private final URL url;
	private final int statusCode;
	private final byte[] content;

	/**
	 * Default constructor
	 * 
	 * @param groupId
	 *            - a groupId of requested url identifier
	 * @param url
	 *            - a requested url
	 * @param statusCode
	 *            - the code of HTTP response
	 * @param content
	 *            - the body of HTTP response
	 */
	public TaskResult(String groupId, URL url, int statusCode, 
			byte[] content) {
		this.groupId = groupId;
		this.url = url;
		this.statusCode = statusCode;
		this.content = content;
	}

	/**
	 * Returns a code of the http's response
	 * 
	 * @return int value of http's response code
	 */
	public int getStatusCode() {
		return statusCode;
	}

	/**
	 * Returns a content of the http's response
	 * 
	 * @return a string with http response
	 */
	public byte[] getContent() {
		return content;
	}

	/**
	 * Returns the given URL to download
	 * 
	 * @return a string with the given URL
	 */
	public URL getUrl() {
		return url;
	}

	/**
	 * Returns a group id
	 * 
	 * @return a string
	 */
	public String getGroupId() {
		return groupId;
	}
	
}
